package com.santu.edu.supporter.biz.order.wm.service.impl;

import com.santu.edu.supporter.biz.order.common.pojo.enums.OrderStatusEnum;
import com.santu.edu.supporter.biz.order.wm.dao.WmOrderDao;
import com.santu.edu.supporter.biz.order.wm.pojo.dto.WmOrderDTO;
import com.santu.edu.supporter.biz.order.wm.pojo.params.WmOrderAddParam;
import com.santu.edu.supporter.biz.order.wm.pojo.params.WmOrderUpdateParam;
import com.santu.edu.supporter.biz.order.wm.service.WmOrderService;
import com.santu.edu.supporter.util.PageData;
import com.santu.edu.supporter.util.UuidUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author luoyaoqi
 * @createTime 2024/2/22
 * @description
 */
@Service
@RequiredArgsConstructor
public class WmOrderServiceImpl implements WmOrderService {

    private final WmOrderDao wmOrderDao;

    @Override
    public Boolean addOrder(WmOrderAddParam addParam) {
        String orderId = UuidUtils.getOrderId();
        WmOrderDTO dto = WmOrderDTO.createItem(addParam, orderId);
        wmOrderDao.addOrder(dto);
        return true;
    }

    @Override
    public Boolean updateOrder(WmOrderUpdateParam updateParam) {
        WmOrderDTO dto = WmOrderDTO.createItem(updateParam);
        wmOrderDao.updateOrder(dto);
        return true;
    }

    @Override
    public Boolean cancelOrder(String orderId) {
        wmOrderDao.cancelOrder(orderId);
        return true;
    }

    @Override
    public PageData<WmOrderDTO> getOrderList(String schoolId, String userId, Integer orderType, int page, int size) {
        return wmOrderDao.getOrderList(schoolId, userId, orderType, page, size);
    }

    @Override
    public void updateOrderStatus(String orderId, OrderStatusEnum orderStatus,OrderStatusEnum nowOrderStatus) {
        wmOrderDao.updateOrderStatus(orderId, orderStatus,nowOrderStatus);
    }
}
